home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Add-Ons / CodeWarrior / DASM 2.0 / DASM Documentation next >
Encoding:
Text File  |  1997-04-22  |  11.8 KB  |  213 lines  |  [TEXT/NISI]

  1. Ideas From the Deep, Ltd.
  2. P.O.Box F-42222
  3. FreePort, Grand Bahama, Bahamas
  4.  
  5.         <http://www.ifd.com>
  6.  
  7. Documentation                            [ 10-Apr-97]
  8.  
  9. This code is released as CodeWare, meaning that you are free to use it, in exchange for sending the author (See "Contacting the Author" below)  a utility and/or piece of source code of similar value. You may distribute this code freely, as long as it is distributed as an entire package, without modifications!
  10.  
  11. If you use any of this code, please give Lane Roathe credit. Thanks!
  12.  
  13. If you make modifications you'd like to see in the distribution package, please feel free to send them to Lane w/a note. It just might happen.
  14.  
  15. Distribution
  16.  
  17. You should have recieved the following files in this distribution:
  18.  
  19. 1. Data Assembler
  20. 2. Data Assembler Panel
  21. 3. DASM Documentation
  22. 4. This ReadMe file
  23. 5. Version History
  24. 6. TEST.SIT (compress test files)
  25. 7. DASMSRC.SIT (compressed source files & projects)
  26. 8. DASM application
  27.  
  28. If you recieved an incomplete distribution, please contact the author. (See "Contacting the Author" below.) And, before writing, the source to the MacOS and DOS applications is not missing, it is not included because these sources rely on ouside libraries and are thus much more difficult to distribute. If you really have a need for the application sources, let me know. I do include the main source file for the DOS application to show how easy it is to modify the actual assembler to fit inside an application shell. (yes, those really are MacOS calls, and yes, they do work…)
  29.  
  30. Re–Distribution
  31.  
  32. Non–profit distribution is allowed/encouraged as long as it is distributed as an entire package, without modifications! For-profit distribution (which includes shareware collections sold in any manner other than at user’s groups) requires that you not only obey the collection requirements (see next paragraph) but you must also donate five (5) copies (at no cost) of the collecction to a high school of your choice, and send the author proof of same w/the authors complimentary copies.
  33.  
  34. If you want to include this software in some sort of software collection (i.e. CD, etc.) you are required to contact the author to insure you distribute the latest version(s), and that you send the author two (2) copies of the collection. (See "Contacting the Author" below.)
  35.  
  36. Copyright & Warranty Disclaimer
  37.  
  38. All software and source code © Copyright 1995-97 Ideas From the Deep, Ltd, All Rights Reserved.
  39.  
  40. Neither Ideas From the Deep nor the program's author make any guarantees about the performance or reliability of this software. Any and all risk in it's use is your own, including loss of data or life.
  41.  
  42. Installation
  43.  
  44. For the compiler, copy the folder "DASM Plugins" to the “Plug Ins” folder in the Metrowerks folder.
  45. To install the Application, just drag it to any folder you wish. You may also want to make an alias of the application and place it on your desktop. Then you can drag files to be assembled onto this alias.
  46.  
  47. Contacting IFD:            Contacting the Author:
  48.  
  49. Ideas From the Deep, Ltd.            Lane Roathe
  50. P.O.Box F-42222                115 Le Point St.
  51. Freeport, Grand Bahama            Arroyo Grande, CA 93420
  52. Bahamas                    (805) 547-1182 / 805-489-2422 fax
  53. <http://www.ifd.com>            lane@xtremeplanet.com    <http://www.fix.net/~lroathe>
  54.  
  55. Ideas From the Deep, Ltd. provides software design & engineering, web page services, artwork, and licensing of code modules. If you are looking for software or web page services, or are an independent contractor looking for a contact house, email us.
  56.  
  57. IFD Data Assembler: What it is
  58.  
  59. The IFD Data Assembler provides a means by which you can write "programs" that generate data. Our specific example of this is the IFD scripting language. Originally this was done on a PC and a true assembler  was used there to write "code" in this language which assembled into p-code the engine interprets. Macintosh assemblers are unable to create plain data files (as best we could determine) so we were forced to create a suitable replacement. This is it.
  60.  
  61. What it isn’t
  62.  
  63. This is not an assembler in the traditional sense of the word. Assemblers have three basic forms of instructions: op-codes, pseudo-ops, and macros. The IFD Data assembler only has two: pseudo-ops and macros. In fact, of the many pseudo-ops available, only a few actually output data.
  64.  
  65. In other words, you won't be writing executable programs with this assembler! (Although if anyone is interested in adding this capability, we'll talk to you.)
  66.  
  67. A Brief Overview
  68.  
  69. The following reference is a brief attempt to document how the IFD Data Assembler works. The design goal for this project was to not only be able to assemble all of our current script code, but to be able to enhance it by allowing the inclusion of C header files. This allows us to create a single header file defining all of the relevant “equates” that can be used in both our script files, as well as our C code files. Obviously, this assembler does not handle all situations that might arise in a .h file, so you must restrict the contents of these files to #define and enum declarations of numeric expressions. (typedef’s will be skipped over.)
  70.  
  71. Please Note: This document assumes that the Pseudo-ops have not been renamed! OK, since we opened that can of worms, you might as well know that all pseudo-ops are defined in the STR# resource of the assembler plug-in file. If you do change any names, you must be sure to enter them in UPPERCASE!
  72.  
  73. In the IFD Data Assembler, all Pseudo-ops are case in-sensitive, while all symbols and macro declarations are case sensitive. (%%4—make this a preference?)
  74.  
  75. Each line in a Data Assembler file follows this format:
  76.  
  77. label        pseudo-op        operand        ;comment
  78.  
  79. Spacing between each element can consist of any number of spaces or tabs, but all elements must be on the same line! A “line” consists of all characters between return characters. Unix files are processed by the IDE, and the assembler understands MS-DOS formatted files without modification. (A must for our development needs.)
  80.  
  81. Lines which are blank or begin with either a semi-colon or slash (i.e.., ; or //) are considered comments and are not processed. Comments on processed lines end processing for that line.
  82.  
  83. Example:
  84.  
  85. // Good comment
  86. ; good comment
  87. /* bad comment, generates an error */
  88.  
  89. Labels are considered global, unless they begin with the local symbol character, which defaults to the period. Global symbols can be referenced anywhere during an assembly, including included files. Local symbols can only be referenced between the first global symbol above, and the first global symbol below, the occurrence of the local symbol. Global symbols can be declared only once in an assembly, while local labels may be declared as many times as desired, as long as each occurrence is outside the scope of all other occurrences.
  90.  
  91. Example:
  92.  
  93. Global 1
  94. .local1
  95. .local2
  96. .local1    // ERROR! (already declared)
  97.  
  98. Global2
  99. .local1
  100. .local2
  101.  
  102. Global1    //ERROR! (previously declared)
  103.  
  104. Included in this distribution is a compressed example (TEST.SIT) which contains the test program used in writing this assembler. Please be sure to look these sources over, as they give you a good idea of how to use the assembler to it’s fullest.
  105. Pseudo-op Reference
  106.  
  107. #include    “filename”
  108.  
  109. This includes the designated file and assembles it before continuing to the next line. Used just as with the C statement, including use of ““ and <> search path definers. (Application does not use search paths!)
  110.  
  111. #define    value
  112.  
  113. As with the C counterpart, but you can only define numeric expressions! (see below.)
  114.  
  115. typedef type def; [or] typedef struct { items; } def;
  116.  
  117. Typedefs are simply skipped over, and generate neither code nor labels, allowing use of C .h files.
  118.  
  119. label        equ    value [or]     label        =    value
  120.  
  121. Equates a label to a value, which may be any valid expression.
  122.  
  123. {label}    d?.?    value{,value…}
  124.  
  125. Output data. DB & DC.B output bytes, DW & DC.W output words, DL, DD, & DC.L output longs, and DT & DC.S output text strings. These are the only pseudo-ops that actually output data! If the optional label is present, it is assigned to the value of the PC before any data is output. You may have any number of items on any given line separated by commas. Values are any legal expression.
  126.  
  127. {label}    org    value
  128.  
  129. Assigns the PC (Program Counter) to the expression ‘value’. If the optional label is present, it too is assigned this value. Please note that this effects only the PC, and not the position of output data, which always starts at offset zero, and works it’s way up, numerically.
  130.  
  131. {label}    ds    value
  132.  
  133. Similar to  org,  but adds “value” to the PC. Useful in creating assembly “structures”. 
  134.  
  135. macro        macroname
  136.  
  137. Defines a macro which can be used later by placing ‘macroname’ in the pseudo-op position and the macro’s parameters in the operand position. During assembly, the assembler takes each line between this macro start line and it’s matching end of macro line, replaces macro parameter uses with the appropriate replacement text, and compiles the line. Here is an example of a macro definition and usage:
  138.  
  139.     org        $8000
  140. symb    =        12345
  141.  
  142.     macro        TestMacro
  143.     dw        {1}, {2}        ;macro parms are {#} or \#
  144.     dl        \3            ; where # is 1..9 (0 = # of parms passed)
  145.     endm
  146.  
  147. Global
  148.     TestMacro    $FACE, symb, .local    ;outputs $FACE303900008008
  149. .local
  150.  
  151. endm
  152.  
  153. End of macro marker. For every ‘macro’ statement, a matching ‘endm’ statement must follow.
  154.  
  155. outfile    “filename”
  156.  
  157. Specifies the name of the file to which the data will be saved. The assembler defaults to outputting the file to the name of the source file with it’s extension replaced by the preferences extension text. Factory settings would create “text.bin” from “test.gor”. The legality of the filename specified by either method (extension replacement or outfile specification) is not checked by the assembler. Instead, if the filename is invalid the assembly will abort with a fatal error after completing. [%%4—find a way to pre-check to give “warning” message & save to some default filename?]
  158.  
  159. outtype    data [or] rsrc [or] link
  160.  
  161. Define output type.  data == data file, rsrc == resource file, link == linked resource (IDE only)
  162.  
  163. resinfo    ‘type’, id#
  164.  
  165. Informs the compiler that you will be saving a resource. This pseudo-op overrides the preferences settings for output type, resource type, and resource id#. The type parameter is a four character sequence, just as you would use in a Macintosh C compiler, and the id# is any valid expression. Please remember that resource id#s are limited to shorts (16 bits) while all assembler values are longs (32 bits).
  166.  
  167.  
  168. Expressions
  169.  
  170. Expressions are any legal numeric statement which includes constants (i.e., 123 or $FEED, or 0xDEAD), symbols (i.e., Global or .local), and operators (i.e., +, -, (, ), etc.…).
  171.  
  172. The order an expression is parsed is a bit odd. Consider:
  173.  
  174. 100+50-25-75
  175.  
  176. The order of evalution is: 25-75, 50 - -50, 100 + 100. In other words, expressions are parsed right to left ( opposite standard parsing rules) but each individual  case is left to right. So, the actual expression is:
  177.  
  178. 100 + (50 - (25 - 75)) = 200
  179.  
  180. Because of the rather unusual parsing order, it is very advisable to group all operations within parenthasis to insure proper evaluation.
  181.  
  182. Other than that, the expression parser is pretty robust, and includes most operations you would expect to find in a C compiler. The following breakdown should cover everhting, but you may want to experiment, as the expression parser is the least scientifically tested portion of DASM. (Hey, I use it daily, but I’ve never written a good stress tester for the parser.)
  183.  
  184.  
  185. Valid Constant identifiers are:
  186.  
  187. $    hexidecimal (base 16)
  188. 0x    hexidecimal (base 16)
  189. %    binary (base 2)
  190. ‘xx’    long, composed of four (4) ASCII bytes (MacOS OSType & ResType) EX: ‘DLOG’ & ‘vers’
  191.  
  192. Valid Operators are:
  193.  
  194. +    addition
  195. -    subtraction (also can be used as a sign)
  196. *    multiplication
  197. /    division
  198. \    mod (remainder)
  199. ~    not (exlusive or w/-1)
  200.  
  201. >>    bitwise right shift (divides)
  202. <<    bitwise left shift (multiplies)
  203. &    bitwise and
  204. |    bitwise or
  205. ^    bitwise exclusive or
  206.  
  207. ==    are equal
  208. !=    are not equal
  209. >    greather than
  210. >    less than
  211. >=    greater than or equal
  212. <=    less than or equal
  213.